/*
 * Copyright (c) 2006, 2023, webrx.cn All rights reserved.
 *
 */

package cn.webrx;

import java.util.Random;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.IntStream;
import java.util.stream.Stream;

/**
 * <p>Project: jse2303 - Stream3</p>
 * <p>Powered by webrx On 2023-07-25 15:39:08</p>
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public class Stream3 {
    public static void main(String[] args) {
        Random rand = new Random();
        IntStream is = IntStream.rangeClosed(1, 100);


        AtomicInteger n = new AtomicInteger(0);

        is.filter(e -> e % 2 == 0).map(e -> e % 10 == 0 ? e + 1 : e).forEach(e -> {
            System.out.printf("%02d ", e);
            if (n.incrementAndGet() % 6 == 0) {
                System.out.println();
            }
        });
        System.out.println();
        Stream<String> ss = Stream.of("java", "javascript", "php", "java1.8", "pythonjava");
        //ss.filter(e -> e.contains("java")).forEach(System.out::println);

        //ss.filter(e -> e.startsWith("java")).forEach(System.out::println);
        //ss.filter(e -> e.endsWith("java")).forEach(System.out::println);
        ss.filter(e -> e.length() >= 4).forEach(System.out::println);
    }
}
